# -*- coding: utf-8 -*-
"""
Created on Thu Jan  4 22:30:31 2024

@author: 28723
"""

import pandas as pd

name = 'sh000300.csv'
df = pd.read_csv('data/' + name, parse_dates=['交易日期'], encoding='gbk')
df.sort_values('交易日期', inplace=True)
df.drop_duplicates(subset=['交易日期'], inplace=True)
df['涨跌幅'] = df['收盘价'].pct_change()
df.to_csv('data/' + name, index=False,encoding='gbk')





import os

name_list = os.listdir('data')

for name in name_list:
    df = pd.read_csv('./data/' + name, parse_dates=['交易日期'], encoding='gbk')
    df.sort_values('交易日期', inplace=True)
    df.drop_duplicates(subset=['交易日期'], inplace=True)
    df['涨跌幅'] = df['收盘价'].pct_change()
    df.to_csv('./data/' + name, index=False,encoding='gbk')






















